package com.newx.test.limit.controller;

import com.newx.limit.annotation.NewxLimit;
import com.newx.test.util.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yxl
 * @date 2024/7/16 0016 14:58
 */
@RequestMapping("/limit")
@RestController
public class LimitController {

    @GetMapping("/test1")
    @NewxLimit(key = "Limiter:test1",limitNum = 1,timeout = 2,msg = "请求太频繁，请稍后再试")
    public R getUserList() {
        List<String> list = new ArrayList<>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        return R.ok().data(list);
    }

    @GetMapping("/test2")
    public R test2() {
        List<String> list = new ArrayList<>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        return R.ok().data(list);
    }
}
